#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/5/10 8:10
# @Author  : LiShan
# @Email   : lishan_1997@126.com
# @File    : look_memory.py
# @Note    : this is note
import psutil

mem = psutil.virtual_memory()
# 系统总计内存
total_memory = float(mem.total) / 1024 / 1024 / 1024
# 系统已经使用内存
use_memory = float(mem.used) / 1024 / 1024 / 1024
use_percent = use_memory / total_memory * 100
round(use_percent, 2)
print('系统总计内存:%.2f GB' % total_memory)
print('系统已经使用内存:%.2f GB' % use_memory)
print('系统使用百分比:%3d%%' % use_percent)